#include <iostream>
using namespace std;

void input(double *op1,double *op2, char *oper);
double add(double *op1,double *op2);
double sub(double *op1,double *op2);
double mul(double *op1,double *op2);
double div(double *op1,double *op2);

double (*oper_fun[])(double*,double*) = {add,sub,mul,div};
int real_op(char *oper);

int main6()
{
	double op1;double op2; char oper;
	int realop;
	int res;
	while(1)
	{
		input(&op1,&op2,&oper);
		realop = real_op(&oper);
		if(realop == 4)
		{
			cout << "oper error!!!" << endl;
			continue;
		}
		res = oper_fun[realop] (&op1,&op2);
		cout << "res = " << res << endl;
	}
	system("pause");
	return 0;
}
double add(double *op1,double *op2)
{
	return *op1 + *op2;
}
double sub(double *op1,double *op2)
{
	return *op1 - *op2;
}
double mul(double *op1,double *op2)
{
	return (*op1) * (*op2);
}
double div(double *op1,double *op2)
{
	return (*op1) / (*op2);
}
void input(double *op1,double *op2, char *oper)
{
	cout << "op1" << endl;
	cin >> *op1;
	cout << "op2" << endl;
	cin >> *op2;
	cout << "oper" << endl;
	cin >> *oper;
}
int real_op(char *oper)
{
	switch(*oper)
	{
	case '+':
		return 0;
		break;
	case '-':
		return 1;
		break;
	case '*':
		return 2;
		break;
	case '/':
		return 3;
		break;
	default:
		return 4;
	}
}
